import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';


class SystemUtil {
  factory SystemUtil() => _getInstance();

  static SystemUtil get instance => _getInstance();

  static SystemUtil _instance;

  SystemUtil._internal() {
    //内部初始化
    //init

  }

  static SystemUtil _getInstance() {
    if (_instance == null) {
      _instance = new SystemUtil._internal();
    }
    return _instance;
  }

  static void statusLightBar() {
    //沉浸式状态栏
    SystemUiOverlayStyle customSystemUiOverlayStyle = SystemUiOverlayStyle(
      systemNavigationBarColor: null,
      //系统底部导航，即虚拟导航键那一块
      systemNavigationBarDividerColor: null,
      //分隔条颜色
      statusBarColor: Colors.white,
      //状态栏颜色
      systemNavigationBarIconBrightness: Brightness.dark,
      //系统导航图标的亮度
      statusBarIconBrightness: Brightness.dark,
      //顶部状态栏图标的亮度
      statusBarBrightness: Brightness.light, //顶部状态栏的亮度
    );
    SystemChrome.setSystemUIOverlayStyle(customSystemUiOverlayStyle);
  }

  static void statusColorBar({Color color}) {
    //沉浸式状态栏
    SystemUiOverlayStyle customSystemUiOverlayStyle = SystemUiOverlayStyle(
      systemNavigationBarColor: color,
      //系统底部导航，即虚拟导航键那一块
      systemNavigationBarDividerColor: null,
      //分隔条颜色
      statusBarColor: color,
      //状态栏颜色
      systemNavigationBarIconBrightness: Brightness.light,
      //系统导航图标的亮度
      statusBarIconBrightness: Brightness.light,
      //顶部状态栏图标的亮度
      statusBarBrightness: Brightness.light, //顶部状态栏的亮度
    );
    SystemChrome.setSystemUIOverlayStyle(customSystemUiOverlayStyle);
  }
}
